package 矩阵.判断矩阵一致性;

import java.util.Arrays;

/**
 * TODO
 *
 * @className: pdjzyzx
 * @description: TODO
 * @author: 等什么柠檬君
 * @date: 2022-05-02 09:23
 *
 * clone 更加节省内存
 **/
public class pdjzyzx {
    public static void main(String[] args) {
       int[][] mat = {{0,0,0},{0,1,0},{1,1,1}};
       int[][] target = {{1,1,1},{0,1,0},{0,0,0}};
       findRotation(mat,target);
    }
    public static boolean findRotation(int[][] mat, int[][] target) {
        for(int k = 0;k < 3;++k){
            for (int[] ints : mat) {
                System.out.println(Arrays.toString(ints));
            }
            if(Arrays.deepEquals(mat,target)){
                System.out.println("有了宝子");
                return true;
            }
            System.out.println();
//            int[][] resultY = new int[mat.length][mat[0].length];
              int[][] resultY = mat.clone();
            for(int i = 0; i < mat.length; ++i){
//                int[] tempY = new int[mat[i].length];
                int[] tempY = mat[i].clone();
                for(int j = mat[i].length - 1; j >= 0 ; --j){
                    tempY[mat[i].length - 1-j] = mat[j][i];
                }
                resultY[i] = tempY;
            }
            mat = resultY;
            if(Arrays.deepEquals(resultY,target)){
                System.out.println("有了宝子");
                return true;
            }
        }
        return false;

    }
}
